<div id="content">
	<div id="diagnostics">
		<h1>Diagnostics</h1>
		<p>This page shows some tests which make it easier to hunt down why things are not working as they should</p>
		<h2>Table of contents</h2>
		<table class="toc">
			<tr><td><a href="#email">Email settings</a></td><td><span class="diag_[val diag.email_all_label]"></span></td></tr>
			<tr><td><a href="#git">Git</a></td><td><span class="diag_[val diag.git_all_label]"></span></td></tr>
			<tr><td><a href="#svn">Subversion</a></td><td><span class="diag_[val diag.svn_all_label]"></span></td></tr>
			<tr><td><a href="#trac">Trac</a></td><td><span class="diag_[val diag.trac_all_label]"></span></td></tr>
		</table>
		<div>
			<a name="email"><h3 class="diag">Email support correctly configured: <span class="diag_[val diag.email_all_label]"></span></h3></a>
			<ul>
				<li>
					<div class="diag_result">
						<label class="diag">Commit email set in config</label>
						<span class="diag_[val diag.email_commit_set_label]"></span>
						[test:!diag.email_commit_set
						<div class="diag_note">
							<p>The 'commit_email_from' option is used when sending commit emails. This will be set as the 'From:' field and the envelope.</p>
							<p>If no 'commit_email_from' is set, the mail is sent from a warning email address. This does not always work. To ensure delivery to everyone (and because it looks nicer), please consider setting it to a sane value. To set the commit_email_from, run the following command:</p>
							<span class="diag_cmd">submin2-admin [val subminenv] config set commit_email_from "Submin &lt;submin@example.tld&gt;"</span>
						</div>]
					</div>
				</li>
				[test:diag.email_commit_set
				<li>
					<div class="diag_result">
						<label class="diag">Commit email sane</label>
						<span class="diag_[val diag.email_commit_sane_label]"></span>
						[test:!diag.email_commit_sane
						<div class="diag_note">
							<p>The 'commit_email_from' option is used when sending commit emails. This will be set as the 'From:' field and the envelope.
							It should contain a name and a valid email address between angle brackets, e.g. <span class="diag_pre">Submin &lt;submin@example.tld&gt;</span></p>
							<p>The current value is: <span class="diag_pre">[val diag.email_commit_current_value]<span></p>
							<p>To set the commit_email_from option, run the following command:</p>
							<span class="diag_cmd">submin2-admin [val subminenv] config set commit_email_from "Submin &lt;submin@example.tld&gt;"</span>
						</div>]
					</div>
				</li>]
				<li>
					<div class="diag_result">
						<label class="diag">SMTP From email set in config</label>
						<span class="diag_[val diag.email_from_set_label]"></span>
						[test:!diag.email_from_set
						<div class="diag_note">
							<p>The 'smtp_from' option is the From: email address used when sending account (re)set emails.</p>
							<p>If no 'smtp_from' is set, the mail is sent from 'root@localhost'. This does not always work. To ensure delivery to everyone (and because it looks nicer), please consider setting it to a sane value. To set the smtp_from, run the following command:</p>
							<span class="diag_cmd">submin2-admin [val subminenv] config set smtp_from "Submin &lt;submin@example.tld&gt;"</span>
						</div>]
					</div>
				</li>
				[test:diag.email_from_set
				<li>
					<div class="diag_result">
						<label class="diag">SMTP From email sane</label>
						<span class="diag_[val diag.email_from_sane_label]"></span>
						[test:!diag.email_from_sane
						<div class="diag_note">
							<p>The 'smtp_from' option is the From: email address used when sending account (re)set emails.
							It should contain a name and a valid email address between angle brackets, e.g. <span class="diag_pre">Submin &lt;submin@example.tld&gt;</span></p>
							<p>The current value is: <span class="diag_pre">[val diag.email_from_current_value]<span></p>
							<p>To set the commit_email_from option, run the following command:</p>
							<span class="diag_cmd">submin2-admin [val subminenv] config set smtp_from "Submin &lt;submin@example.tld&gt;"</span>
						</div>]
					</div>
				</li>]
				<li>
					<div class="diag_result">
						<label class="diag">Might be able to send:</label>
						<span class="diag_[val diag.email_might_work_smtp_from_label]"></span>
						[test:!diag.email_might_work_smtp_from
						<div class="diag_note">
							<p>There are probably (see disclaimer below) problems sending email:</p>

							<span class="diag_pre">[val diag.email_might_work_smtp_from_msg]</span>

							<p>For normal sending (not this test) Submin will first try to send via SMTP with the various smtp_* options (using sane defaults if not set). If that fails, it will fallback to local (via sendmail executable).</p>

							<p>For this test only SMTP will be tested if smtp_hostname is set, otherwise only local will be tested.</p>

							<p>Due to the nature of e-mail, you will only find out if you can send e-mail by actually sending an e-mail. This test does not send e-mails to prevent annoyance. Therefore, these tests are very limited and can only give an indication; If this test does not detect any problem, it does not guarantee that the email will be deliverd, and if this test does detect a problem in some cases there is none. YMMV.</p>

						</div>]
					</div>
				</li>
			</ul>
			<a name="git"><h3 class="diag">Git support working correctly: <span class="diag_[val diag.git_all_label]"></span></h3></a>
			<ul>
				<li>
					<div class="diag_result">
						<label class="diag">Git enabled</label>
						<span class="diag_[val diag.enabled_git_label]"></span>
						<div class="diag_note">
							[test:diag.enabled_git To disable, run the following command: <span class="diag_cmd">submin2-admin [val subminenv] config set vcs_plugins svn</span>]
							[else To enable, run the following command: <span class="diag_cmd">submin2-admin [val subminenv] git init</span>]
						</div>
					</div>
				</li>
				[test:diag.enabled_git
				<li>
					<div class="diag_result">
						<label class="diag">Git dir set in config</label>
						<span class="diag_[val diag.git_dir_set_label]"></span>
						[test:!diag.git_dir_set
						<div class="diag_note">
							<p>To set the git_dir, run the following command:</p>
							<span class="diag_cmd">submin2-admin [val subminenv] config set git_dir git</span>
						</div>]
					</div>
				</li>
				<li>
					<div class="diag_result">
						<label class="diag">Git dir permissions</label>
						<span class="diag_[val diag.git_dir_perms_label]"></span>
						[@test:!diag.git_dir_perms
						<p>The following subdirs of git_dir have wrong permissions:</p>
						<ul>[iter:diag.git_dir_perms_wrong <li>[ival.dir] ([ival.reason])</li>]</ul>
						<p>They should be either:
						<ul>
							<li>owned by <span class="diag_pre">git-user:web-user</span> and have at least <span class="diag_pre">rwx</span> permissions for 'user' and <span class="diag_pre">r-x</span> permissions for 'group' (final git dir, subdirs)</li>
							<li>have at least <span class="diag_pre">r-x</span> permissons for 'other' (subdirs)</li>
						</ul>
						]
					</div>
				</li>
				<li>
					<div class="diag_result">
						<label class="diag">Git repository permissions</label>
						<span class="diag_[val diag.git_repos_correct_perms_label]"></span>
						[test:!diag.git_repos_correct_perms
						<div class="diag_note">
							<p>The following directories (relative to the git directory) have incorrect permissions or ownerships:</p>
							<table>
								<tr><th>Relative path</th><th>Permission bits</th><th>Ownership</th></tr>
								[iter:diag.git_repos_bad_dirs <tr><td>[ival.name]</td><td>[ival.mode]</td><td>[ival.user]:[ival.group]</td></tr>]
							</table>
							<p>The directory should be owned by the git user and set to the web user group. The directory should also be setgid. They can be corrected with:</p>
							<span class="diag_cmd">submin2-admin [val subminenv] unixperms fix</span>
						</div>]
					</div>
				</li>
					<li>
					<div class="diag_result">
						<label class="diag">Up-to-date hooks</label>
						<span class="diag_[val diag.git_hooks_all_new_label]"></span>
						[test:!diag.git_hooks_all_new
						<div class="diag_note">
							<p>The following repositories have outdated hooks:</p>
							<ul>[iter:diag.git_old_hook_repos <li>[ival.0] ([ival.1])</li>]</ul>
							<p>They can be upgraded with:</p>
							<span class="diag_cmd">submin2-admin [val subminenv] git hook update <em>reponame</em></span>
							<p>If you want to upgrade all repositories at once, run the following command:</p>
							<span class="diag_cmd">submin2-admin [val subminenv] git hook update</span> (note: without any repository name)
						</div>]
					</div>
				</li>
				<li>
					<div class="diag_result">
						<label class="diag">Git local ssh</label>
						<span class="diag_[val diag.git_admin_test_label]"></span>
						[test:!diag.git_admin_test
						<div class="diag_note">
							<p>Could not issue admin commands through SSH. Error message:</p>
<div class="diag_pre">[val diag.git_admin_test_errmsg]</div>

<h4>1) Run 'git init'</h4>
<p>Have you run 'git init' yet? This command is necessary since it needs root privileges (to add a unix user and to set permissions).<p>
<span class="diag_cmd">submin2-admin [val subminenv] git init</span>

<h4>2) Re-run diagnostics</h4>
<p>After running 'git init', please re-run diagnostics to see if this solved the problem. If not, continue</p>

<h4>3) Check config</h4>
<p>Please check that git_ssh_host_internal, git_ssh_port and git_user are setup correctly. You can check this with:</p>
<p><span class="diag_cmd">submin2-admin [val subminenv] config get <em>value</em></span></p>

<h4>4) Check if SSH can connect</h4>
<p>Next check that you can actually connect to SSH:</p>
<p><span class="diag_cmd">ssh <em>[val diag.git_user]</em>@<em>[val diag.git_ssh_host_internal]</em> -p <em>[val diag.git_ssh_port]</em> -i [val subminenv]/conf/id_dsa</span></p>
<p>(it should give a message like: <span class="diag_cmd">submin2-admin git admin is not supposed to be called by users.</span>)
</p>
						</div>]
					</div>
				</li>
				<li>
					<div class="diag_result">
						<label class="diag">Git public hostname correct</label>
						<span class="diag_[val diag.git_hostname_ok_label]"></span>
						[test:!diag.git_hostname_ok
						<div class="diag_note">
							<p>The 'git_ssh_host' config is not set, or it is set to a local address. Is 'git init' run? If not, do this first before re-checking:<p>
							<span class="diag_cmd">submin2-admin [val subminenv] git init</span>
							<p>If 'git init' has been run and the problem still exists, please set a hostname reachable by everyone with the following command:</p>
							<span class="diag_cmd">submin2-admin [val subminenv] config set git_ssh_host <em>public_hostname</em></span>
						</div>]
					</div>
				</li>
				]
			</ul>
			<a name="svn"><h3 class="diag">Svn support working correctly: <span class="diag_[val diag.svn_all_label]"></span></h3></a>
			<ul>
				<li>
					<div class="diag_result">
						<label class="diag">SVN enabled</label>
						<span class="diag_[val diag.enabled_svn_label]"></span>
						<div class="diag_note">
							[test:diag.enabled_svn To disable, run the following command: <span class="diag_cmd">submin2-admin [val subminenv] config set vcs_plugins git</span>]
							[else To enable, run the following command: <span class="diag_cmd">submin2-admin [val subminenv] config set vcs_plugins git,svn</span>]
						</div>
					</div>
				</li>
				[test:diag.enabled_svn
				<li>
					<div class="diag_result">
						<label class="diag">SVN dir set in config</label>
						<span class="diag_[val diag.svn_dir_set_label]"></span>
						[test:!diag.svn_dir_set
						<div class="diag_note">
							<p>To set the svn_dir, run the following command:</p>
							<span class="diag_cmd">submin2-admin [val subminenv] config set svn_dir svn</span>
						</div>]
					</div>
				</li>
				[test:!diag.svn_apache_modules_exec_ok
				<li>
					<div class="diag_result">
						<label class="diag">Apache modules</label>
						<span class="diag_fail"></span>
						<div class="diag_note">
							<p>Could not execute apachectl or load the server-info URL to test if modules are loaded. Error message was:</p>
							<div class="diag_pre">[val diag.svn_apache_modules_errmsg]</div>
							<p>If the above commands all fail with 'No such file or directory', then maybe the 'apachectl' binary is named differently on your system. Please report this as a bug.</p>

							<p>If the above commands can be found, but fail to verify because 'apachectl' complains about lack of permissions, you can make sure that the apache module 'info'
							is loaded and reachable from localhost. Submin will then try to get the list of modules from the 'info' modules by retrieving a URL.</p>

							<p>By default, this URL is 'http://localhost/server-info?list', but if you need to change it for some reason, you can do so with the following command:
							<span class="diag_cmd">submin2-admin [val subminenv] config set apache_server_info_url "http://localhost/server-info?list"</span></p>

							<p>If the 'internal URL get' fails this URL could not be used, please check the error message there and try to correct the error.</p>
						</div>
					</div>
				</li>
				][else
				[iter:diag.svn_apache_modules
				<li>
					<div class="diag_result">
						<label class="diag">Apache module '[ikey]'</label>
						<span class="diag_[test:ival ok][else fail]"></span>
						[test:!ival
						<div class="diag_note">
							The module '[ikey]' was not loaded. Please make sure it is.
						</div>]
					</div>
				</li>]
				]
				]
			</ul>
			<a name="trac"><h3 class="diag">Trac support working correctly: <span class="diag_[val diag.trac_all_label]"></span></h3></a>
			<ul>
				<li>
					<div class="diag_result">
						<label class="diag">Trac enabled</label>
						<span class="diag_[val diag.enabled_trac_label]"></span>
						<div class="diag_note">
							[test:diag.enabled_trac To disable, run the following command: <span class="diag_cmd">submin2-admin [val subminenv] config set enabled_trac no</span>]
							[else To enable, run the following command: <span class="diag_cmd">submin2-admin [val subminenv] config set enabled_trac yes</span>]
						</div>
					</div>
				</li>
				[test:diag.enabled_trac
				<li>
					<div class="diag_result">
						<label class="diag">Trac installed</label>
						<span class="diag_[val diag.installed_trac_label]"></span>
						[test:!diag.installed_trac
						<div class="diag_note">
							<p> The 'trac-admin' command was not found, please install Trac. If you have installed Trac, but it cannot be found, check if the env_path config value is set correctly:</p>
							<span class="diag_cmd">submin2-admin [val subminenv] config get env_path</span>.
							<p>Set it with:</p>
							<span class="diag_cmd">submin2-admin [val subminenv] config set env_path <em>yourpath</em></span>
						</div>]
					</div>
				</li>
				<li>
					<div class="diag_result">
						<label class="diag">Trac dir set in config</label>
						<span class="diag_[val diag.trac_dir_set_label]"></span>
						[test:!diag.trac_dir_set
						<div class="diag_note">
							<p>To set the trac_dir, run the following command:</p>
							<span class="diag_cmd">submin2-admin [val subminenv] config set trac_dir trac</span>
						</div>]
					</div>
				</li>
				<li>
					<div class="diag_result">
						<label class="diag">Trac sync configured</label>
						<span class="diag_[val diag.trac_acl_hook_label]"></span>
						[test:!diag.trac_acl_hook
						<div class="diag_note">
							<p>The variable 'acl_hook' has not been set. It probably works on the defaults, but leaving it unconfigured can cause slow down during commits because of DNS resolving if trac sync is enabled. We recommend setting the ACL like this:</p>
							<p><span class="diag_cmd">submin2-admin [val subminenv] config set acl_hook <em>[val diag.trac_acl_hook_recommendation]</em></span></p>
						</div>]
					</div>
				</li>
				<li>
					<div class="diag_result">
						<label class="diag">Trac sync accessible</label>
						<span class="diag_[val diag.trac_sync_access_label]"></span>
						[test:!diag.trac_sync_access
						<div class="diag_note">
							<p>Git hook does not have access to submin to sync trac.
							Please make sure that the IP-address is in the ACL. Set it with:</p>
							<p><span class="diag_cmd">submin2-admin [val subminenv] config set acl_hook <em>[val diag.trac_acl_hook_recommendation]</em></span></p>

							<p>The error message was:</p>
							<div class="diag_pre">[val diag.trac_sync_access_msg]</div>
						</div>]
					</div>
				</li>
				<li>
					<div class="diag_result">
						<label class="diag">htpasswd export directory exists</label>
						[test:diag.trac_htpasswd_file
						<span class="diag_[val diag.trac_htpasswd_dir_exists_label]"></span>
						[test:!diag.trac_htpasswd_dir_exists
						<div class="diag_note">
							<p>The setting htpasswd_file is set, but the directory does not exist.
							To export the htpasswd_file, please make sure that [val diag.trac_htpasswd_dir] exists.</p>
						</div>]
						][else
						<span class="diag_[val diag.trac_htpasswd_file_label]"></span>
						<div class="diag_note">
							<p>The setting htpasswd_file is not set. We will
							not export an htpasswd file for trac. If you don't
							use tracd for running your trac-environment you are
							probably fine. Otherwise, please point
							htpasswd_file to the proper location for your
							password file.</p>
						</div>]
					</div>
				</li>
				<li>
					<div class="diag_result">
						<label class="diag">Trac environments connected</label>
						<span class="diag_[val diag.trac_envs_all_connected_label]"></span>
						[test:!diag.trac_envs_all_connected
						<div class="diag_note">
						<p>The following Trac environments are orphaned:</p>
						<ul>[iter:diag.trac_envs_orphaned
							<li>[ival]</li>]
						</ul>
						<p>No repository is found that connects to them (should be the same name as the trac name). Maybe it is the result of a deleted repository?</p>
						</div>]
					</div>
				</li>
				<li>
					<div class="diag_result">
						<label class="diag">Trac environments config</label>
						<span class="diag_[val diag.trac_envs_complete_label]"></span>
						[test:!diag.trac_envs_complete
						<div class="diag_note">
						<p>The following Trac environments have missing/incorrect configuration. Please correct the values to the one below:</p>
						<ul>[iter:diag.trac_envs_missing_config
							<li>
								[ival.trac_env] (<a href="[val diag.trac_base_url][val ival.trac_env]/admin/general/plugin#no1" class="external" target="_blank">Trac admin panel</a>)
								<ul>
									<li>
										<div class="diag_pre">[iter:ival.missing_configs \[[ikey]\]
[iter:ival <span class="diag_[test:ival.fatal no][else warn] diag_inline"></span>[ival.option] = [ival.value]
][test:!ilast
]]</div>
										<div>The trac.ini file is: <span class="diag_pre">[val diag.trac_dir]/[ival.trac_env]/conf/trac.ini</span></div>
									</li>
								</ul>
							</li>]
						</ul>
						<p>Options from the 'components' section can be enabled in its Trac admin panel (Trac may ask you to login first). Other options have to be configured in the trac.ini of the corresponding trac environment.</p>
						</div>]
					</div>
				</li>
				]
			</ul>
		</div>
	</div>
</div>
